WOLF core
WOLF: A Modular Estimation Framework for Robotics
XXXXXXXXXXXXXXXXXXXXXXXXvoid(0)" frameborder="0" name="MSearchResults" id="MSearchResults">
string_utils.h
Go to the documentation of this file.
1// WOLF - Copyright (C) 2020-2026
2// Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
3// Authors: Joan Solà Ortega (jsola@iri.upc.edu) and
4// Joan Vallvé Navarro (jvallve@iri.upc.edu)
5// All rights reserved.
6//
7// This file is part of WOLF: http://www.iri.upc.edu/wolf
8// WOLF is free software: you can redistribute it and/or modify
9// it under the terms of the GNU General Public License version 3
10// as published by the Free Software Foundation.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19#pragma once
20
21#include <Eigen/Dense>
22#include <ctime>
23#include <iostream>
24#include <string>
25#include <sstream>
26
27namespace wolf
28{
29// date now in string
30std::string dateTimeNow();
31
32inline std::string dateTimeNow()
33{
34 // Get date and time for archiving purposes
35 std::time_t rawtime;
36 std::time(&rawtime);
37 const std::tm* timeinfo = std::localtime(&rawtime);
38 char time_char[30];
39 std::strftime(time_char, sizeof(time_char), "%d/%m/%Y at %H:%M:%S", timeinfo);
40 std::string date_time(time_char);
41 return date_time;
42}
43} // namespace wolf
44
45namespace std
46{
47template <typename Derived>
48std::string to_string(const Eigen::DenseBase<Derived>& mat)
49{
50 std::stringstream ss;
51 if (mat.cols() == 1)
52 ss << mat.transpose();
53 else
54 ss << std::endl << mat;
55 return ss.str();
56}
57} // namespace std
Definition: jet.h:1355
std::string to_string(const Eigen::DenseBase< Derived > &mat)
Definition: string_utils.h:48
Definition: capture_base.h:23
std::string dateTimeNow()
Definition: string_utils.h:32